<?php
class Post_Model_Comment extends Zend_Db_Table
{
        protected $_name="comment";
        protected $_primary = 'id';
	   
    public function insertComment($arrParam = null, $option = null)
  	{
  		$row = $this->fetchNew();		  	
		$row->userid       =$arrParam['userid'];
		$row->postid           =$arrParam['postid'];
		$row->content       =$arrParam['content'];		
		$row->createdate       =$arrParam['createdate'];
	  	return $row->save();
  	}
  	
	public function countPost($idpost){

  		$db = Zend_Registry::get('connectDB');
  		$count = $db->fetchOne("SELECT COUNT(*) AS count FROM comment where postid = '".$idpost."'" );
  		
  		return $count;
  		
  	}
  	
	public function listItemByPost($idpost,$page,$pagesize){

  		$db = Zend_Registry::get('connectDB');  			
  		$offset = ($page - 1) * $pagesize;	
		$sql = "SELECT *  FROM comment where postid =  '".$idpost."' limit ".$offset.",".$pagesize." ";
  		$result = $db->fetchAll($sql);
  	
  		return $result;
  	}
  	
  	
  	
  	
  	
}